package cn.edu.nuc.ssm.dao;

import cn.edu.nuc.ssm.dto.*;
import cn.edu.nuc.ssm.entity.PayIncome;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PayIncomeMapper {
    @Delete({
        "delete from pay_income",
        "where id3 = #{id3,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id3);

    @Insert({
        "insert into pay_income (id3, uid, ",
        "ctid, money, date, ",
        "detail, ex_flags)",
        "values (#{id3,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, ",
        "#{ctid,jdbcType=INTEGER}, #{money,jdbcType=DECIMAL}, #{date,jdbcType=CHAR}, ",
        "#{detail,jdbcType=VARCHAR}, #{exFlags,jdbcType=INTEGER})"
    })
    int insert(PayIncome record);

    int insertSelective(PayIncome record);

    @Select({
        "select",
        "id3, uid, ctid, money, date, detail, ex_flags",
        "from pay_income",
        "where id3 = #{id3,jdbcType=INTEGER}"
    })
    @ResultMap("cn.edu.nuc.ssm.dao.PayIncomeMapper.BaseResultMap")
    PayIncome selectByPrimaryKey(Integer id3);

    int updateByPrimaryKeySelective(PayIncome record);

    @Update({
        "update pay_income",
        "set uid = #{uid,jdbcType=INTEGER},",
          "ctid = #{ctid,jdbcType=INTEGER},",
          "money = #{money,jdbcType=DECIMAL},",
          "date = #{date,jdbcType=CHAR},",
          "detail = #{detail,jdbcType=VARCHAR},",
          "ex_flags = #{exFlags,jdbcType=INTEGER}",
        "where id3 = #{id3,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(PayIncome record);

    /**
     * 插入支出
     * @param record 插入支出的数据
     * @return
     */
    int insertZhichu(PayIncome record);

    /**
     * 插入收入
     * @param record 插入收入的数据
     * @return
     */
    int insertShouru(PayIncome record);


    List<SumShouDto> findbyUidSumShou(@Param("uid") Integer uid, @Param("year") String year);

    List<SumZhiDto> findbyUidSumZhi(@Param("uid") Integer uid, @Param("year") String year);

    List<SumJiduZhiDto> findbyUidSumZhiByJidu(@Param("uid") Integer uid, @Param("year") String year);

    List<SumJiduShouDto> findbyUidSumShouByJidu(@Param("uid") Integer uid, @Param("year") String year);

    List<SumMonthZhiDto> findbyUidSumZhiByMonth(@Param("uid") Integer uid, @Param("year") String year);

    List<SumMonthShouDto> findbyUidSumShouByMonth(@Param("uid") Integer uid, @Param("year") String year);

    List<ZhiTypeNameAndmoneyDto> findbyUidSumZhiByYearAndType(@Param("uid") Integer uid, @Param("year") String year);

    List<ZhiTypeNameAndmoneyDto> findbyUidSumZhiByMonthAndType(@Param("uid") Integer uid, @Param("year") String year,@Param("month")String month);

    List<ZhiTypeNameAndmoneyDto> findbyUidSumZhiByJiduAndType(@Param("uid") Integer uid, @Param("year") String year,@Param("quarter")Integer quarter);

    List<ConsumeAnalyDto> fenxiZhiByUidAndType(@Param("uid") Integer uid, @Param("year") String year);

    List<ConsumeAnalyDto> fenxiZhiByType( @Param("year") String year);

    int deletebyCtidandUid(@Param("ctid")Integer ctid,@Param("uid")Integer uid);


    int deletebyCtid(@Param("ctid")Integer ctid);

   List<PayIncome> findbyCtid(@Param("ctid")Integer ctid);




}